package com.example.demo.service.impl;

import com.example.demo.StaticValue;
import com.example.demo.bean.User;
import com.example.demo.mapper.UserMapper;
import com.example.demo.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;

public class LoginServiceImpl implements LoginService {

    @Autowired
    private UserMapper userMapper;

    /**
     *
     * @param account 用户账号
     * @param password 用户密码
     * @return 登录验证结果
     * @describe 验证用户账号和密码
     */
    @Override
    public int verify(String account, String password) {
        User user = userMapper.selectUserByAccount(account);
        System.out.println("my: " + user);
        if (user == null) {
            return StaticValue.NOUSER;
        }else if (!user.getPassword().equals(password))
            return StaticValue.FAULT;
        else {
            return StaticValue.SUSSES;
        }
    }
}
